package com.alibaba.citrus.cr.mn.order.center.facade.function.assemble;

import com.alibaba.lattice2.epoch.sdk.model.Result;
import com.google.common.collect.Maps;

import java.util.List;
import java.util.Map;
import java.util.Objects;

/**
 * @author zhangxiaorui
 * @ClassName AbstractOrderBizAssemble
 * @description: TODO
 * @date 2023/05/17 09:48
 * @version: 1.0
 */
public interface OrderBizAssemble<T> {

    String SHIP_TO_PARTY = "shipToParty";
    String SOLD_TO_PARTY = "soldToParty";
    String SALES_ORGANIZATION = "salesOrganization";
    String SALES_DEPARTMENT = "salesDepartment";
    String SALES_CHANNEL = "salesChannel";
    String BUSINESS_UNIT_CODE = "businessUnitCode";
    String BUSINESS_CHANNEL = "businessChannel";
    String LOGISTIC_WAREHOUSE = "logisticWarehouse";
    String INVENTORY_AVAILABLE_QTY = "inventoryAvailableQuantity";
    String SC_ITEM_GROUP = "scItemGroup";
    String SC_ITEM_UNIT = "scItemUnit";
    String SC_ITEM_INFO = "scItemInfo";
    String SC_ITEM_CONVERT_RELATION = "scItemConvertRelation";
    String MEMBER_INFO = "memberInfo";
    String CREDIT_INFO = "creditInfo";
    String COST_CENTER = "costCenter";
    String FORECAST_ORDER = "forecastOrder";

    /**
     * 数据查询
     * @param t
     * @return
     */
    Map<String, Object> query(T t);

    /**
     * 数据查询
     * @param tList
     * @return
     */
    Map<String, Object> query(List<T> tList);

    /**
     * 数据组装
     * @param queryResponseMap
     * @param req
     */
     Result<String> assemble(Map<String, Object> queryResponseMap, T req);

    default <R> Map<String, R> getBizInfoMap(Map<String, Object> queryResponseMap, String bizType, Class<R> Clazz) {
        Object o = queryResponseMap.get(bizType);
        if(Objects.isNull(o)) {
            return Maps.newHashMap();
        }
        return (Map<String, R>) o;
    }
}
